<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <div style="width:100%;margin: 0 auto;height: 100%">
        <table id="classd" style="width: 100%;"></table>
        <div id="win" class="easyui-window" data-options="closed:true,modal:true" title="导入学生" style="width:340px;">
				<form style="padding:10px" method="post" id="addUserForm">
					<input class="easyui-filebox" style="width:300px">
					<div style="padding:5px;text-align:center;">
					<a href="#" class="easyui-linkbutton" icon="icon-ok" id="userSaveBtn">确定</a>
					<a href="#" class="easyui-linkbutton" icon="icon-cancel" id="userCancelBtn">取消</a>
					</div>
				</form>
			</div>
  	</div>
  	<script>
        $(function () {
           	$("#userSaveBtn").click(function() {
        		//配置提交表单的信息
        		$("#addUserForm").form({
        			url:'user_add.action',
        			success:function(data){
        				alert(data)
        				if(data == 1) {
        					//重置表单
            				$("#addUserForm").form('reset');
            				//关闭创建
            				$("#win").window('close');
            				//重新加载表格中的数据，用于显示添加的新数据
            				$("#userinfo").datagrid('reload');
        				}else {
        					alert("添加失败");
        					//重置表单
            				$("#addUserForm").form('reset');
            				//关闭创建
            				$("#win").window('close');
        				}
        				
        			}
        		});
        		
        		//提交表单
        		$("#addUserForm").submit();
        	});
			//取消按钮事件
        	$("#userCancelBtn").click(function(){
        		 $("#win").window('close');//关闭创建的窗口
        	});

            $("#classd").datagrid({
                columns:[[
                    {field:'className',title:'班级',width:15+'%',align:'center'},
                    {field:'sNo',title:'学号',width:10+'%',align:'center'},
                    {field:'sName',title:'姓名',width:10+'%',align:'center'},
                    {field:'group',title:'小组',width:20+'%',align:'center'},
                    {field:'sIntegral',title:'积分',width:10+'%',align:'center'},
                    {field:'sLeCurrency',title:'学习币',width:10+'%',align:'center'},
                    {field:'operate',title:'操作',width:27+'%',align:'center',formatter:function (value,row,index) {
                        return '<a class="change" href="#" iconCls:"icon-add">编辑</a>';
                    }},
                ]],
                data:[
                    {className:'物联网1402',sNo:201227140128,sName:'叶志英',group:'第三组',sIntegral:18,sLeCurrency:288},
                    {className:'物联网1402',sNo:201227140128,sName:'叶志英',group:'第三组',sIntegral:18,sLeCurrency:288},
                    {className:'物联网1402',sNo:201227140128,sName:'叶志英',group:'第三组',sIntegral:18,sLeCurrency:288},
                    {className:'物联网1402',sNo:201227140128,sName:'叶志英',group:'第三组',sIntegral:18,sLeCurrency:288},
                    {className:'物联网1402',sNo:201227140128,sName:'叶志英',group:'第三组',sIntegral:18,sLeCurrency:288},
                    {className:'物联网1402',sNo:201227140128,sName:'叶志英',group:'第三组',sIntegral:18,sLeCurrency:288},
                    
                ], 
                pagination:true,//在表格下方添加分页工具栏
                pageList:[5,10,15,20],
                pageNumber:1,
                pageSize:5,
                toolbar: [{
                    iconCls: 'icon-add',//工具栏按钮的图标
                    handler: function(){//handler是当点击对应按钮时，要执行操作
                        $("#win").window('open');//打开指定窗口
                    }
                	},'-',{
                    iconCls: 'icon-ok',
                    handler: function(){
                        $('#userinfo').edatagrid('saveRow');
                    }
                }]
            });
            
        })
    </script>
</body>
</html>
